package cn.org.xuanguang.kepler.hormos.rdb.plugin;

import cn.org.xuanguang.kepler.hormos.rdb.plugin.mysql.MysqlDdlSQLBuilder;
import cn.org.xuanguang.kepler.hormos.rdb.plugin.postgre.PgDdlBuilder;
import cn.org.xuanguang.kepler.metadata.relational.KeplerMetaColumn;
import cn.org.xuanguang.kepler.metadata.relational.KeplerMetaTable;

/**
 * ddl sql 构建
 */
public interface DdlSQLBuilder {

    public static DdlSQLBuilder of(String dialat) {
        switch (dialat) {
            case "postgre":
                return new PgDdlBuilder();
            case "mysql":
                return new MysqlDdlSQLBuilder();
            default:
                return new MysqlDdlSQLBuilder();
        }
    }
    // 创建数据库
    public String getCreateDatabaseDDL(String databaseName);
    // 创建数据库及配置编码
    public String getCreateDatabaseDDL(String databaseName, String charset);
    // 删除数据库
    public String getDropDatabaseDDL(String databaseName);
    // 创建表
    public String getCreateTableDDL(String databaseName, String tableName);
    /**
     * @param keplerMetaTable
     * @return
     */
    public String getCreateTableDDL(KeplerMetaTable keplerMetaTable);

    /**
     *
     * @param keplerMetaColumn
     * @return
     */
    String getDbDataType(KeplerMetaColumn keplerMetaColumn);

    public String getDropTableDDL(KeplerMetaTable keplerMetaTable);
    public String getAlterTableDDL(KeplerMetaTable keplerMetaTable);
    public String getCreateIndexDDL(KeplerMetaTable keplerMetaTable);
    public String getDropIndexDDL(KeplerMetaTable keplerMetaTable);
    // 修改表名
    public String getRenameTableDDL(String databaseName, String oldTableName, String newTableName);
}
